//
//  UITabBarItem+YTAdd.m
//  tesDemo02
//
//  Created by 拓客营 on 2022/3/21.
//

#import "UITabBarItem+YTAdd.h"

@implementation UITabBarItem (YTAdd)

+ (UIBarButtonItem *)yt_itemWithTitle:(nullable NSString *)title target:(nullable id)target action:(nullable SEL)action {
    
    return [self yt_itemWithTitle:title style:UIBarButtonItemStylePlain target:target action:action];
}

+ (UIBarButtonItem *)yt_itemWithTitle:(nullable NSString *)title style:(UIBarButtonItemStyle)style target:(nullable id)target action:(nullable SEL)action {
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:title style:style target:target action:action];
    [item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor], NSFontAttributeName:[UIFont systemFontOfSize:14]} forState:UIControlStateNormal];
    
    return item;
}

+ (UIBarButtonItem *)yt_itemWithImageName:(NSString *)imageName target:(nullable id)target action:(nullable SEL)action {
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateHighlighted];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    button.size = CGSizeMake(30, 30);
    
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}


@end
